package com.smarttable.ysd;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import com.umeng.analytics.MobclickAgent;

public class AdminSettingActivity extends PreferenceActivity {
    Preference mSystemPreference;
    private CheckBoxPreference mCheckPreference;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//        setSupportActionBar(toolbar);
        addPreferencesFromResource(R.xml.activity_admin_setting);
        mSystemPreference = findPreference("enterSystem");
        mSystemPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                try {
                    Intent intent = new Intent();
                    ComponentName componentName = new ComponentName("com.android.launcher3","com.android.launcher3.Launcher");
                    intent.setComponent(componentName);
                    startActivity(intent);
                    finish();
                }catch (Exception e){
                    try {
                        Intent intent = new Intent();
                        ComponentName componentName = new ComponentName("com.android.launcher","com.android.launcher2.Launcher");
                        intent.setComponent(componentName);
                        startActivity(intent);
                        finish();
                    }catch (Exception e1){

                    }
                }
                return true;
            }
        });
        mCheckPreference = (CheckBoxPreference)findPreference("forbid_entertainment");
        mCheckPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                App.forbidEntertainment = (boolean)newValue;
                return true;
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }



}
